#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT([apr_dbd_odbc], [1.0])
AC_ARG_WITH( 
	[apr], 
	[AS_HELP_STRING( [--with-apr=DIR], [the --with-apr=DIR switch is required, and must point to an Apache 2.2 or APR 1.2 top-level directory] )], 
	[APR=${withval}],
	[AC_MSG_FAILURE( [the --with-apr=DIR switch is required, and must point to an Apache 2.2 or APR 1.2 top-level directory] )]
)
APRBIN=
if test "x${APR}" != "xyes"; then
  APRBIN=${APR}/bin/
  prefix=${APR}
  echo using APR in ${APR}
fi
[ODBC_INCLUDES="`${APRBIN}apu-1-config --includes`"]
[ODBC_LDFLAGS="`${APRBIN}apu-1-config --link-libtool` -version-info 0:1:0"]
[ODBC_CFLAGS="`${APRBIN}apr-1-config --cflags` `${APRBIN}apr-1-config --cppflags`"]
if test "x${ODBC_INCLUDES}" = "x"; then
   AC_MSG_FAILURE([unable to execute apu-1-config from PATH, try --with-apr=DIR])
fi
[echo ODBC_INCLUDES \(from APR\) = ${ODBC_INCLUDES}]
[echo ODBC_LDFLAGS \(from APR\) = ${ODBC_LDFLAGS}]
[echo ODBC_CFLAGS \(from APR\) = ${ODBC_CFLAGS}]
AC_SUBST([ODBC_INCLUDES])
AC_SUBST([ODBC_LDFLAGS])
AC_SUBST([ODBC_CFLAGS])
AC_CONFIG_SRCDIR([./apr_dbd_odbc.c])
AM_INIT_AUTOMAKE

# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_LIBTOOL

# Checks for libraries.
AC_CHECK_LIB([odbc],[SQLConnect],[], [AC_MSG_FAILURE([libodbc not found - An ODBC Manager (e.g. unixODBC) is  required to build apr_dbd_odbc])])
# Checks for header files.
AC_CHECK_HEADERS([sql.h], [], [AC_MSG_FAILURE([sql.h not found - An ODBC Manager (e.g. unixODBC) must be installed to build apr_dbd_odbc])])
AC_CHECK_HEADERS([sqlext.h], [], [AC_MSG_FAILURE([sqlext.h not found - An ODBC Manager (e.g. unixODBC) must be installed to build apr_dbd_odbc])])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T

# Checks for library functions.
AC_CHECK_FUNCS([strpbrk strspn])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
